package effect;

import java.util.ArrayList;
import java.util.List;

import card.Card;
import core.Core;
import effect.Effect.EffectType;

public class EffectUtil {
	
	/**
	 * returns a List of all the effects in the given list that has the given type.
	 * @param list
	 * @param type
	 * @return
	 */
	public static List<Effect> getSubList(List<Effect> list, EffectType type){
		List<Effect> returnList = new ArrayList<Effect>();
		for(Effect e : list){
			if(e.isEffectType(type))
				returnList.add(e);
		}
		return returnList;
	}
	
	/**
	 * finds and returns the Card with given effect.
	 * Returns null if no card was found.
	 * @param e
	 */
	public static Card getCard(Effect e){
		for(Card c : Core.getInstance().getAllCards()){
			if(c.hasEffect(e)){
				return c;
			}
		}
		return null;
	}

}
